# -*- coding: utf-8 -*-
"""
@Version : 
@Author  : ChenMZ
@Time    : 2025/09/23
@File    : CPUStaticInfoMonitorView.py
@Desc    : 
@Modify  : 
"""
from PyQt5 import QtGui
from typing import Optional
from PyQt5.QtWidgets import QWidget, QAbstractItemView, QHeaderView
from ui.DevMonitorUI.CpuMonitor.CpuStaticInfoMonitorUI import Ui_Form
from tool.signal_bus import CpuMonitorSignalBus
from model.CpuViewModel.StaticModel import CpuStaticInfoTableViewModel


class CpuStaticInfoView(QWidget, Ui_Form):
    def __init__(self):
        super().__init__()
        self.setupUi(self)
        self.model = CpuStaticInfoTableViewModel(["属性", "值"])

        self.initialization()
        self.register_signal()

    def initialization(self):
        self.TableView.setModel(self.model)
        self.TableView.setSelectionMode(QAbstractItemView.SingleSelection)
        self.TableView.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.TableView.setAlternatingRowColors(True)
        self.TableView.verticalHeader().hide()
        self.TableView.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)

    def register_signal(self):
        pass

    def showEvent(self, a0: Optional[QtGui.QShowEvent]) -> None:
        print("Show CpuStaticInfoView")
        CpuMonitorSignalBus.signal_get_attr_req.emit("get_detail_info")
        CpuMonitorSignalBus.signal_dynamic_cap.emit(False)

